// 标记设置里面公用方法
import { mapActions, mapGetters } from 'vuex'
import { postSignById, putMarkSetting } from 'src/boot/program-v2/sign'
export default {
  name: 'sign-mixin',
  data () {
    return {
    }
  },
  computed: {
    ...mapGetters([
      'permissions',
      'userInfo',
      'signFileData'
    ]),
    isGBtnPer () {
      return this.permissions.includes(this.Enums.SYS_PERMISSION.G_PAIR_BTN.value)
    },
    isTranFlag () {
      const markerIds = this.signFileData.markerList || []
      const enableFlag = this.signFileData.enableFlag
      return enableFlag && markerIds.map(v => v.id).includes(this.userInfo.user_id)
    },
    isShowDui () {
      const enableFlag = this.signFileData.enableFlag
      return enableFlag
    }
  },
  methods: {
    ...mapActions([
      'getSignFile'
    ]),
    async onSignFile ({ path, transferableFlag }) {
      const ret = await postSignById(path, !transferableFlag)
      ret.success && this.$message.success('操作成功')
      this.refreshFun && this.refreshFun()
    },

    getSignMarking () {
      this.getSignFile()
    },
    async putSignMarking () {
      const res = await putMarkSetting()
      console.log(res)
    }
  },
  mounted () {
    this.getSignMarking()
  }
}
